import request from '@/utils/request'

export function pageStorePayChannel(data) {
  return request({
    method: 'post',
    params: {
      _gp: 'admin.storeStatistics',
      _mt: 'pageStorePayChannel',
      ...data
    }
  })
}

export function pageStoreSkuSmmmary(data) {
  return request({
    method: 'post',
    params: {
      _gp: 'admin.storeStatistics',
      _mt: 'storeOrderSkuSummary',
      ...data
    }
  })
}

export function exportOrderSkuSummary(startTime, endTime, storeId, storeName, isOnline, isFinance) {
  startTime = startTime && startTime !== '' ? startTime : ''
  endTime = endTime && endTime !== '' ? endTime : ''
  isFinance = isFinance || false
  storeId = storeId || ''
  const exportOrderSummaryHref = process.env.HOST + '/excel/exportOrderSkuSummary'
  const a = document.createElement('a')
  a.setAttribute('href', encodeURI(exportOrderSummaryHref + '?startTime=' + startTime + '&endTime=' + endTime + '&storeId=' + storeId + '&storeName=' + storeName + '&isOnline=' + isOnline + '&isFinance=' + isFinance))
  a.click()
  a.remove()
}

export function exportSkuSummary(startTime, endTime, storeId, state, stateStr, orderNo, goodsEntryType) {
  startTime = startTime && startTime !== '' ? startTime : ''
  endTime = endTime && endTime !== '' ? endTime : ''
  state = state || ''
  stateStr = stateStr && stateStr !== '' ? stateStr : ''
  orderNo = orderNo && orderNo !== '' ? orderNo : ''
  const exportOrderSummaryHref = process.env.HOST + '/excel/exportSkuSummary'
  const a = document.createElement('a')
  a.setAttribute('href', encodeURI(exportOrderSummaryHref + '?startTime=' + startTime + '&endTime=' + endTime + '&storeId=' + storeId + '&state=' + state + '&stateStr=' + stateStr + '&orderNo=' + orderNo + '&goodEntryType=' + goodsEntryType))
  a.click()
  a.remove()
}
